import { getIntl } from 'umi';
// 数据库字典表
import { MyChartOption } from '@/components/EchartsComponent';

export const DATABASE_TYPE = {
  // 站点类型
  SITE_TYPE: 100001,
  // 设备类型
  DEVICE_TYPE: 100002,
  // 通讯协议
  COMMUNICATION_PROTOCOL: 100003,
  // 事件大类
  EVENT_LARGE_CATEGORY: 100004,
  // 事件小类
  EVENT_SMALL_CATEGORY: 100005,
  // 事件等级
  EVENT_GRADE: 100006,
  // 用户状态
  USER_STATUS: 100007,
  // 升级设备类型
  UPDATE_DEVICE_TYPE: 100009,
  // 租户菜单版本
  MENU_TYPE: 100010,
  // 升级状态
  UPDATE_STATUS: 100011,
  // 在线状态
  ONLINE_STATUS: 100012,
  // 工作状态
  WORK_STATUS: 100013,
  // 功率模式
  POWER_MODE: 100014,
  CHARGE_STATUS: 100016,
  //角色状态
  ROLE_STATUS: 100017,
  // 空调设备状态
  AIR_CONDITIONING_EQUIPMENT_STATUS: 100018,
  // 启用设备
  ENABLE_DEVI: 100019,
  // 除湿工作状态
  WORKING_STATE_OF_DEHUMIDIFICATION: 100020,
  // 除湿故障状态
  DEHUMIDIFICATION_FAULT_STATE: 100021,
  // 除湿报警状态
  DEHUMIDIFICATION_ALARM_STATE: 100022,
  // 除湿工作模式
  DEHUMIDIFICATION_WORKING_MODE: 100023,
  // 液冷运行状态
  LIQUID_COOLING_OPERATION_STATE: 100024,
  // 液冷运行状态模式
  LIQUID_COOLING_OPERATION_STATE_MODE: 100025,
  // 液冷开关机
  LIQUID_COOLED_SWITCH: 100026,
  LIQUID_COOLED_FAULT_LEVE: 200004,
  // 电站运行状态
  STATION_RUN_STATUS: 100027,
  // 电池故障类型
  BATTERY_FAILURE_TYPE: 100028,
  // PCS运行状态
  PCS_STATUS: 100031,
  OPERATE_TYPE: 100032,
  // 温度异常等级
  TEMP_ANOMALY_LAVEL: 100033,
  // 采集异常类型
  COLLECTION_EXCEPTION_TYPE: 100034,
  //喷洒状态
  SPARYSTATE: 200003,
  // 电站概览运行状态
  OVERVIEW_RUN_STATUS: 100036,
  // 告警设备类型
  EVENT_DEVICE_TYPE: 100038,
  // 总断路器状态
  BREAKER_STATUS: 100039,
  // 总断路器故障
  BREAKER_BREAKDOWN: 100040,
  //电表精度
  METER_ACCURACY: 200008,
  //包管理组件类型
  COM_TYPE: 200002,
  OTA_LEVE_STATUS: 200005,
  // 电压等级
  VOLT_LEVEL: 200007,
  FAULT_TYPE: 200009,
  // 告警类型
  ALARM_TYPE: 200011,
  // 漏液状态
  LIQUID_STATUS: 200014,
  // 液冷运行状态
  LIQUID_RUNINF_STATUS: 10024,
  // 温差模式
  TEMP_MODE: 200015,
  // 电表类型
  METER_TYPE: 200017,
  // 储能柜组件类型
  ESS_CABINET_TYPE: 200016,
};

// 充放类型类型
export const CHARGE_TYPE = {
  1: {
    text: '可充可放',
  },
  2: {
    text: '不充不放',
  },
  3: {
    text: '只充不放',
  },
  4: {
    text: '只放不充',
  },
};

// 充放类型类型
export const getChargeType = () => {
  const getIntlObject = getIntl();
  return {
    1: {
      text: getIntlObject.formatMessage({
        id: 'strategyControl.strategyTracking.chargeableAndDischargeable',
      }),
    },
    2: {
      text: getIntlObject.formatMessage({
        id: 'strategyControl.strategyTracking.noChargeAndNoDischarge',
      }),
    },
    3: {
      text: getIntlObject.formatMessage({ id: 'strategyControl.strategyTracking.onlyCharge' }),
    },
    4: {
      text: getIntlObject.formatMessage({ id: 'strategyControl.strategyTracking.onlyDischarge' }),
    },
  };
};

//时段
export const TIME_TYPE = {
  '1': {
    text: '尖段',
  },
  '2': {
    text: '峰段',
  },
  '3': {
    text: '平段',
  },
  '4': {
    text: '谷段',
  },
};

//时段
export const getTimeType = () => {
  const getIntlObject = getIntl();
  return {
    '1': {
      text: getIntlObject.formatMessage({ id: 'strategyControl.strategyTracking.sharp' }),
    },
    '2': {
      text: getIntlObject.formatMessage({ id: 'strategyControl.strategyTracking.peak' }),
    },
    '3': {
      text: getIntlObject.formatMessage({ id: 'strategyControl.strategyTracking.shoulder' }),
    },
    '4': {
      text: getIntlObject.formatMessage({ id: 'strategyControl.strategyTracking.offPeak' }),
    },
  };
};

//功率单位
export const POWER_UNIT = {
  kW: {
    text: 'kW',
  },
  MW: {
    text: 'MW',
  },
};

//充电桩单位
export const PIE_UNIT = {
  kW: {
    text: 'kW',
  },
};

//容量单位
export const CAPACITY_UNIT = {
  kWh: {
    text: 'kWh',
  },
  MWh: {
    text: 'MWh',
  },
  GWh: {
    text: 'GWh',
  },
};

// 光伏单位
export const PHO_UNIT = {
  kWp: {
    text: 'kWp',
  },
  MWp: {
    text: 'MWp',
  },
};

//设备类型
export const DEVICE_TYPE = {
  3: {
    text: 'PCS',
    order: 1,
  },
  1: {
    text: '一体柜',
    order: 2,
  },
  2: {
    text: '电池箱',
    order: 3,
  },
};

//PCS类型
export const PCS_TYPE = {
  '1': {
    text: '组串式',
  },
  '2': {
    text: '集中式',
  },
};

//充电桩类型
export const CHARGING_PILE_TYPE = {
  1: {
    text: '直流',
  },
  2: {
    text: '交流',
  },
};

//电池箱类型
export const BATTERY_BOX_TYPE = {
  1: {
    text: '风冷',
  },
  2: {
    text: '液冷',
  },
};

//充放电状态
export const CHARGING_DISCHARGING_STATUS = {
  0: {
    text: '静置',
    status: 'Default',
  },
  1: {
    text: '充电',
    status: 'Success',
  },
  2: {
    text: '放电',
    status: 'Processing',
  },
  3: {
    text: '故障',
    status: 'Error',
  },
};

//充放电状态
export const getChargeAndDischargeStatus = () => {
  const getIntlObject = getIntl();
  return {
    0: {
      text: getIntlObject.formatMessage({ id: 'strategyControl.strategyTracking.standby' }),
      status: 'Default',
    },
    1: {
      text: getIntlObject.formatMessage({ id: 'strategyControl.strategyTracking.charge' }),
      status: 'Success',
    },
    2: {
      text: getIntlObject.formatMessage({ id: 'strategyControl.strategyTracking.discharge' }),
      status: 'Processing',
    },
    3: {
      text: getIntlObject.formatMessage({ id: 'strategyControl.strategyTracking.fault' }),
      status: 'Error',
    },
  };
};

// 空图表状态
export const getEmptyOptions = () => {
  const getIntlObject = getIntl();
  return {
    grid: {
      left: 25,
      right: 5,
      top: 60,
      bottom: 15,
      containLabel: true,
      show: true,
      borderColor: 'transparent',
      backgroundColor: '#fff',
    },
    xAxis: {
      data: [],
      show: true,
      axisLine: {
        show: true,
        lineStyle: {
          color: '#ddd',
        },
      },
      axisLabel: {
        color: '#222',
      },
    },
    yAxis: {
      data: [],
      show: true,
      axisLine: {
        show: true,
        lineStyle: {
          color: '#ddd',
        },
      },
      axisLabel: {
        color: '#222',
      },
    },
    graphic: [
      {
        type: 'image',
        silent: true,
        style: {
          image: require('@/assets/img/empty.png'),
          width: 180,
          height: 120,
        },
        bounding: 'raw',
        top: 'center',
        left: 'center',
        invisible: false,
      },
      {
        type: 'text', // 类型：文本
        left: 'center',
        top: '60%',
        silent: true, // 不响应事件
        invisible: false, // 有数据就隐藏
        style: {
          fill: '#222',
          text: getIntlObject.formatMessage({ id: 'global.noDataYet' }),
          fontFamily: 'Microsoft YaHei',
          fontSize: '14px',
        },
      },
    ],
  };
};

// 空饼图数据
export const EMPTY_PIE_OPTIONS: MyChartOption = {
  series: [
    {
      type: 'pie',
      radius: ['40%', '70%'],
      avoidLabelOverlap: false,
      label: {
        show: true,
        position: 'center',
      },
      emphasis: {
        label: {
          show: true,
          fontSize: 40,
          fontWeight: 'bold',
        },
      },
      labelLine: {
        show: false,
      },
      data: [],
    },
  ],
};

//光伏容量单位
export const PHOTOVOLTAIC_CAPACITY_UNIT = {
  MWp: {
    text: 'MWp',
  },
  kWp: {
    text: 'kWp',
  },
};

//储能电价分类
export const getElectricityPriceType = () => {
  const getIntlObject = getIntl();
  return {
    1: {
      text: getIntlObject.formatMessage({ id: 'electricityPrice.electrovalence' }),
    },
    2: {
      text: getIntlObject.formatMessage({ id: 'electricityPrice.capacityPayment' }),
    },
    3: {
      text: getIntlObject.formatMessage({ id: 'electricityPrice.demandElectricityPrice' }),
    },
  };
};

//储能电价分类 1-用户电价;2-上网电价;3-补贴电价;4-下网电价
export const getPvElectricityPriceType = () => {
  const getIntlObject = getIntl();
  return {
    1: {
      text: getIntlObject.formatMessage({ id: 'electricityPrice.userElectricityPrice' }),
    },
    2: {
      text: getIntlObject.formatMessage({ id: 'electricityPrice.feedInTariff' }),
    },
    3: {
      text: getIntlObject.formatMessage({ id: 'electricityPrice.subsidizedElectricityPrice' }),
    },
    4: {
      text: getIntlObject.formatMessage({ id: 'electricityPrice.offGridElectricityPrice' }),
    },
  };
};

export const getTOUPriceType = () => {
  const getIntlObject = getIntl();
  return {
    1: {
      text: getIntlObject.formatMessage({ id: 'electricityPrice.TOU' }),
    },
    2: {
      text: getIntlObject.formatMessage({ id: 'electricityPrice.unifiedElectricityPrice' }),
    },
  };
};

//电价电压等级：1、小于1kV;2、1-10kV;3、35-110kV;4、大于220kV */
export const getPriceVoltageLevel = () => {
  const getIntlObject = getIntl();
  return {
    1: {
      text: `${getIntlObject.formatMessage({ id: 'electricityPrice.lessThan' })}1kV`,
    },
    2: {
      text: '1-10kV',
    },
    3: {
      text: '35-110kV',
    },
    4: {
      text: `${getIntlObject.formatMessage({ id: 'electricityPrice.outweigh' })}220kV`,
    },
  };
};

//电价类型 0-单一制;1-两部制
export const getSystemElectricityPriceType = () => {
  const getIntlObject = getIntl();
  return {
    0: {
      text: getIntlObject.formatMessage({ id: 'electricityPrice.unitarySystem' }),
    },
    1: {
      text: getIntlObject.formatMessage({ id: 'electricityPrice.twoPartTariff' }),
    },
  };
};

//光伏并网模式：1-自发自用；2-余电上网；3-全额上网
export const getPvGridConnectedMode = () => {
  const getIntlObject = getIntl();
  return {
    1: {
      text: getIntlObject.formatMessage({ id: 'electricityPrice.spontaneousSelfUse' }),
    },
    2: {
      text: getIntlObject.formatMessage({
        id: 'electricityPrice.excessElectricityConnectedInternet',
      }),
    },
    3: {
      text: getIntlObject.formatMessage({ id: 'electricityPrice.fullInternetAccess' }),
    },
  };
};
